package conf

import (
	"fmt"
	"gopkg.in/yaml.v2"
	"io/ioutil"
)

type Config struct {
	Listen string `yaml:"listen"`
	DbHost string `yaml:"dbhost"`
	DbName string `yaml:"dbname"`
	DbPwd  string `yaml:"dbpwd"`
	DbUser string `yaml:"dbuser"`
}

var Cfg Config

//读取Yaml配置文件,
//并转换成conf对象
func init() {
	//应该是 绝对地址
	yamlFile, err := ioutil.ReadFile("conf.yaml")
	if err != nil {
		fmt.Println(err.Error())
	}
	err = yaml.Unmarshal(yamlFile, &Cfg)
	if err != nil {
		fmt.Println(err.Error())
	}
}
